package cz.idsv.web.mvc.model.service;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Service;

import cz.idsv.web.mvc.model.dao.DocumentDao;
import cz.idsv.web.mvc.model.entity.DocumentEntity;


@Service("DocumentService")
public class DocumentServiceImpl implements DocumentService {

	@Autowired()
	private DocumentDao documentDao;
	
	
	public Collection<DocumentEntity> findDocuments() throws DataAccessException{
		return documentDao.findDocuments();
	}

	public void save(DocumentEntity documentEntity) {
		documentDao.save(documentEntity);
	}

	@Secured ({"ROLE_ADMIN"})
	public void delete(DocumentEntity documentEntity) {
		documentDao.delete(documentEntity);
	}

	public DocumentEntity findDocumentById(Integer id)
			throws DataAccessException {
		return documentDao.findDocumentById(id);
	}
}
